package com.qmerak.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qmerak.entity.PostUnitEntity;
import com.qmerak.service.IPostUnitService;

/**
 * @author Shaohong•Cheng
 * @mail shaohong726@126.com
 * @date 2013-5-19
 * @project WebTest
 */
@Controller
@RequestMapping("/unit")
public class UnitAction {
	@Autowired
	private IPostUnitService unitService;

	@ResponseBody
	@RequestMapping(value = "add", method = RequestMethod.POST)
	public void add(PostUnitEntity entity) {
		unitService.add(entity);
	}

	@ResponseBody
	@RequestMapping(value = "delete", method = RequestMethod.POST)
	public void delete(PostUnitEntity entity) {
		unitService.delete(entity);
	}

	@ResponseBody
	@RequestMapping(value = "update", method = RequestMethod.POST)
	public void update(PostUnitEntity entity) {
		unitService.update(entity);
	}

	@ResponseBody
	@RequestMapping(value = "all", method = RequestMethod.GET)
	public List<PostUnitEntity> all() {
		return unitService.list();
	}

}
